package com.time.sky.controller;


import com.time.sky.entity.Contract;
import com.time.sky.entity.Contracts;
import com.time.sky.mapper.ContractMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class ContractController {

    @Autowired
    ContractMapper contractMapper;


    @CrossOrigin
    @RequestMapping("/contract/selectAll")
    public List<Contract> findAll(){
        List<Contract> contracts = contractMapper.selectContractList();
        return  contracts;
    }
    @CrossOrigin
    @RequestMapping("/contract/mohu")
    public List<Contract> mohu(@RequestBody Contracts contracts){
        List<Contract> contractss = contractMapper.mohu(contracts);
        return  contractss;
    }
    @CrossOrigin
    @RequestMapping("/contract/addContract")
    public void addContract(@RequestBody Contract contract){
        contractMapper.addContract(contract);
    }
    @CrossOrigin
    @RequestMapping("/contract/updateContract")
    public void updateContract(@RequestBody Contract contract){
        contractMapper.updateConttract(contract);
    }

    @CrossOrigin
    @RequestMapping("/contract/deleteOne")
    public void deleteOne(int cid){
        contractMapper.deleteOne(cid);
    }

}
